package IU;

import Controladores.CtrlAMBOperario;
import Entidades.Rol;
import Entidades.Area;
import Entidades.Modulo;
import Entidades.Rolareamodulo;
import Controladores.CtrlRol;
import Controladores.CtrlArea;
import Controladores.CtrlModulo;
import Controladores.CtrlOperariorol;
import Controladores.CtrlRolAreaModulo;
import Entidades.Operario;
import Entidades.Operariorol;
import java.util.Collection;
import java.util.List;
import java.util.Vector;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;

public class Permisos extends javax.swing.JFrame {

    Rol rol;
    Area area;
    Modulo modulo;
    CtrlRol contrRol;
    CtrlArea contrArea;
    CtrlModulo contrModulo;
    CtrlRolAreaModulo controladorRolareamodulo;
    CtrlAMBOperario controladoroperario;
    CtrlOperariorol ctrloperariorol;
    private List listar;
    private List listam;
    private List listaa;
    private List listaram;
    private List<Rolareamodulo> listaModulosASeleccionar = new ArrayList<Rolareamodulo>();
    private List<Rolareamodulo> listaModulosSeleccionados = new ArrayList<Rolareamodulo>();
    private List<Rolareamodulo> listapermisosactuales = new ArrayList<Rolareamodulo>();
    private List<Rolareamodulo> listaRAMparam = new ArrayList<Rolareamodulo>();
    Rol miRol = null;
    Area miArea = null;
    TablaPersonalizada tableModel;
    private List<Operariorol> listram;
    private List lista;
    TablaPersonalizada tableModel1;
    private List operol;

    public Permisos(String o) {
        initComponents();
        String operario = o;
        jTextFieldUsuario3.setText(operario);

        contrRol = new CtrlRol();
        contrArea = new CtrlArea();
        contrModulo = new CtrlModulo();
        controladorRolareamodulo = new CtrlRolAreaModulo();
        controladoroperario = new CtrlAMBOperario();
        ctrloperariorol = new CtrlOperariorol();
        cargarComboRol();
        cargarComboArea();

    }

    private void cargarComboRol() {
        try {
            listar = contrRol.buscarTodosRol();
            System.out.println("tamaño de la lista de roles " + listar.size());
            jComboBoxRol.removeAllItems();
            for (int i = 0; i < listar.size(); i++) {
                Vector fila = new Vector();
                Rol ro = (Rol) listar.get(i);
                //acá filtro y pongo en el combo sólo los roles q no tengan fecha de baja
                //if(ro.getFechaFin().equals("") || ro.getFechaFin() == "" ){
                if (ro.getFechaFin() == null ? "" != null : ro.getFechaFin().equals("")) {
                    fila.add(ro.getNombreRol());
                    jComboBoxRol.addItem(fila.get(0));
                }
            }
        } catch (Exception e) {
            e.printStackTrace(System.out);
        }
    }

    private void cargarComboArea() {
        try {
            listaa = contrArea.buscarTodosArea();
            System.out.println("tamaño de la lista de áreas " + listaa.size());
            jComboBoxArea.removeAllItems();
            for (int i = 0; i < listaa.size(); i++) {
                Vector fila = new Vector();
                Area are = (Area) listaa.get(i);
                //acá filtro y pongo en el combo sólo las áreas q no tengan fecha de baja
                if (are.getFechaFin().equals("") || are.getFechaFin() == null) {
                    fila.add(are.getNombreArea());
                    jComboBoxArea.addItem(fila.get(0));
                }
            }
        } catch (Exception e) {
            e.printStackTrace(System.out);
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        GestorPesajeJpaPU2EntityManager = java.beans.Beans.isDesignTime() ? null : javax.persistence.Persistence.createEntityManagerFactory("GestorPesajeJpaPU2").createEntityManager();
        operarioQuery = java.beans.Beans.isDesignTime() ? null : GestorPesajeJpaPU2EntityManager.createQuery("SELECT o.apellido  FROM Operario o ");
        operarioList = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : operarioQuery.getResultList();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        jLabelApellidoCon = new javax.swing.JLabel();
        jComboBoxRol = new javax.swing.JComboBox();
        jButtonBuscarMod = new javax.swing.JButton();
        jComboBoxArea = new javax.swing.JComboBox();
        jLabelApellidoCon2 = new javax.swing.JLabel();
        jPanel5 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTablePermisos = new javax.swing.JTable();
        jButtonRedefinirPermisosSelecc = new javax.swing.JButton();
        jPanel9 = new javax.swing.JPanel();
        jTextFieldUsuario4 = new javax.swing.JTextField();
        jPanel2 = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jComboBoxAN = new javax.swing.JComboBox();
        jButton1 = new javax.swing.JButton();
        jPanel6 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTablemodulos = new javax.swing.JTable();
        jScrollPane4 = new javax.swing.JScrollPane();
        jTablem = new javax.swing.JTable();
        jPanel8 = new javax.swing.JPanel();
        jTextFieldUsuario3 = new javax.swing.JTextField();
        jButtonSalir = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Permisos - Sistema Gestor de Pesaje para Bodegas"); // NOI18N

        jTabbedPane1.setForeground(new java.awt.Color(102, 0, 102));
        jTabbedPane1.setFont(new java.awt.Font("Segoe UI", 3, 12));

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED), "Seleccionar:", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 3, 12), new java.awt.Color(102, 0, 102))); // NOI18N

        jLabelApellidoCon.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabelApellidoCon.setText("Rol:");

        jComboBoxRol.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jComboBoxRol.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jComboBoxRolItemStateChanged(evt);
            }
        });
        jComboBoxRol.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxRolActionPerformed(evt);
            }
        });

        jButtonBuscarMod.setFont(new java.awt.Font("Segoe UI", 3, 12));
        jButtonBuscarMod.setForeground(new java.awt.Color(102, 0, 102));
        jButtonBuscarMod.setMnemonic('B');
        jButtonBuscarMod.setText("Buscar Permisos Actuales");
        jButtonBuscarMod.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonBuscarModActionPerformed(evt);
            }
        });

        jComboBoxArea.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jComboBoxArea.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jComboBoxAreaItemStateChanged(evt);
            }
        });
        jComboBoxArea.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxAreaActionPerformed(evt);
            }
        });

        jLabelApellidoCon2.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabelApellidoCon2.setText("Área:");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabelApellidoCon)
                .addGap(18, 18, 18)
                .addComponent(jComboBoxRol, 0, 141, Short.MAX_VALUE)
                .addGap(38, 38, 38)
                .addComponent(jLabelApellidoCon2)
                .addGap(18, 18, 18)
                .addComponent(jComboBoxArea, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(53, 53, 53)
                .addComponent(jButtonBuscarMod)
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelApellidoCon)
                    .addComponent(jComboBoxRol, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelApellidoCon2)
                    .addComponent(jComboBoxArea, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonBuscarMod))
                .addContainerGap(19, Short.MAX_VALUE))
        );

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED), "Permisos", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 3, 12), new java.awt.Color(102, 0, 102))); // NOI18N

        jScrollPane1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jScrollPane1MouseClicked(evt);
            }
        });

        jTablePermisos.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Módulo", "Visible"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Object.class, java.lang.Boolean.class
            };
            boolean[] canEdit = new boolean [] {
                false, true
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTablePermisos.setColumnSelectionAllowed(true);
        jTablePermisos.getTableHeader().setReorderingAllowed(false);
        jTablePermisos.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTablePermisosMouseClicked(evt);
            }
        });
        jTablePermisos.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                jTablePermisosPropertyChange(evt);
            }
        });
        jScrollPane1.setViewportView(jTablePermisos);
        jTablePermisos.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

        jButtonRedefinirPermisosSelecc.setFont(new java.awt.Font("Segoe UI", 3, 12));
        jButtonRedefinirPermisosSelecc.setForeground(new java.awt.Color(102, 0, 102));
        jButtonRedefinirPermisosSelecc.setText("Redefinir Permisos");
        jButtonRedefinirPermisosSelecc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonRedefinirPermisosSeleccActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 618, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                .addContainerGap(489, Short.MAX_VALUE)
                .addComponent(jButtonRedefinirPermisosSelecc)
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 205, Short.MAX_VALUE)
                .addGap(24, 24, 24)
                .addComponent(jButtonRedefinirPermisosSelecc)
                .addContainerGap())
        );

        jPanel9.setBorder(javax.swing.BorderFactory.createTitledBorder("Usuario Registrado"));

        jTextFieldUsuario4.setEditable(false);

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addComponent(jTextFieldUsuario4, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTextFieldUsuario4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(28, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(88, Short.MAX_VALUE))
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addGap(1588, 1588, 1588)
                    .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(26, 26, 26)
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(87, Short.MAX_VALUE))
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addGap(195, 195, 195)
                    .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(238, Short.MAX_VALUE)))
        );

        jPanel3.getAccessibleContext().setAccessibleName("");
        jPanel5.getAccessibleContext().setAccessibleName("");

        jTabbedPane1.addTab("Permisos", jPanel1);

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED), "Seleccionar Operario", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 3, 12), new java.awt.Color(102, 0, 102))); // NOI18N

        jLabel1.setFont(new java.awt.Font("Segoe UI", 1, 12));
        jLabel1.setText("Apellido y Nombre: ");

        jComboBoxAN.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        org.jdesktop.swingbinding.JComboBoxBinding jComboBoxBinding = org.jdesktop.swingbinding.SwingBindings.createJComboBoxBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, operarioList, jComboBoxAN);
        bindingGroup.addBinding(jComboBoxBinding);

        jButton1.setFont(new java.awt.Font("Segoe UI", 3, 12));
        jButton1.setForeground(new java.awt.Color(102, 0, 102));
        jButton1.setText("Buscar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addComponent(jLabel1)
                .addGap(18, 18, 18)
                .addComponent(jComboBoxAN, javax.swing.GroupLayout.PREFERRED_SIZE, 183, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 203, Short.MAX_VALUE)
                .addComponent(jButton1)
                .addGap(35, 35, 35))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jComboBoxAN, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton1))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED), "Modulos Accesibles", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 3, 12), new java.awt.Color(102, 0, 102))); // NOI18N

        jTablemodulos.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null}
            },
            new String [] {
                "Area", "Rol", "Cargo"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTablemodulos.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTablemodulosMouseClicked(evt);
            }
        });
        jScrollPane2.setViewportView(jTablemodulos);

        jScrollPane3.setViewportView(jScrollPane2);

        jTablem.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null},
                {null, null},
                {null, null},
                {null, null}
            },
            new String [] {
                "Módulo", "Activo/ No Activo"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane4.setViewportView(jTablem);

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 579, Short.MAX_VALUE))
                .addContainerGap(33, Short.MAX_VALUE))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(32, 32, 32)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(39, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(32, 32, 32)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel6, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(84, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(43, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Consultar permisos asignados a Operarios", jPanel2);

        jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED), "Usuario Registrado", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 3, 12), new java.awt.Color(102, 0, 102))); // NOI18N

        jTextFieldUsuario3.setEditable(false);
        jTextFieldUsuario3.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel8Layout.createSequentialGroup()
                .addContainerGap(20, Short.MAX_VALUE)
                .addComponent(jTextFieldUsuario3, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTextFieldUsuario3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(28, Short.MAX_VALUE))
        );

        jButtonSalir.setFont(new java.awt.Font("Segoe UI", 3, 12));
        jButtonSalir.setForeground(new java.awt.Color(102, 0, 102));
        jButtonSalir.setText("Salir");
        jButtonSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSalirActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 770, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonSalir))
                .addGap(20, 20, 20))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGap(32, 32, 32)
                        .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButtonSalir))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 549, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(46, Short.MAX_VALUE))
        );

        bindingGroup.bind();

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-1030)/2, (screenSize.height-644)/2, 1030, 644);
    }// </editor-fold>//GEN-END:initComponents

private void jButtonSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSalirActionPerformed
    this.dispose();
}//GEN-LAST:event_jButtonSalirActionPerformed

    //no hace falta q actualice
    private void actualizarComboRol(List lista1) {
        jComboBoxRol.removeAllItems();
        for (int i = 0; i < lista1.size(); i++) {
            Vector fila = new Vector();
            Rol ro = (Rol) lista1.get(i);
            fila.add(ro.getNombreRol());
            jComboBoxRol.addItem(fila.get(0));
        }
    }

    //no hace falta q actualice
    private void actualizarComboArea(List lista2) {
        jComboBoxArea.removeAllItems();
        for (int i = 0; i < lista2.size(); i++) {
            Vector fila = new Vector();
            Area are = (Area) lista2.get(i);
            fila.add(are.getNombreArea());
            jComboBoxArea.addItem(fila.get(0));
        }
    }

    private void cargarTabla(List<Rolareamodulo> listaModulosASeleccionar) {    //List<Rolareamodulo> listaModulosASeleccionar  List listaram
        DefaultTableModel modelo = (DefaultTableModel) jTablePermisos.getModel();
        try {
            if (listaModulosASeleccionar != null && !listaModulosASeleccionar.isEmpty()) {//listaModulosASeleccionar listaram
                System.out.println("Tamaño de lista de permisos actuales" + listaModulosASeleccionar.size());//listaModulosASeleccionar listaram
                for (int i = 0; i < listaModulosASeleccionar.size(); i++) {//listaModulosASeleccionar   listaram
                    Vector fila = new Vector();
                    Rolareamodulo ram = (Rolareamodulo) listaModulosASeleccionar.get(i);//listaModulosASeleccionar  listaram
                    //acá filtro y pongo en el combo sólo los modulos q no tengan fecha de baja
                    if (ram.getModulo().getFechaFin().equals("") || ram.getModulo().getFechaFin() == null) {
                        fila.add(ram.getModulo().getNombreModulo());
                        fila.add(ram.getVisible());
                        modelo.addRow(fila);
                        this.jTablePermisos.setModel(modelo);
                    }
                }
            }
        } catch (Exception e) {
            System.out.println(e);
            System.out.println("No trajo la consulta. Tamaño de lista permisos actuales: " + listapermisosactuales.size());
        }
    }

private void jButtonBuscarModActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBuscarModActionPerformed

    Object esterol = jComboBoxRol.getSelectedItem();
    System.out.println("Object esterol = jComboBoxRol.getSelectedItem(): " + esterol);
    String nombrerol = esterol.toString();
    System.out.println("String nombrerol = esterol.toString(): " + nombrerol);
    try {
        rol = contrRol.buscarRolNombre(nombrerol);
        System.out.println("rol = contrRol.buscarRolNombre(nombrerol): " + rol);
    } catch (Exception e) {
        e.printStackTrace(System.out);
        System.out.println("no encontró el nombre del rol seleccionado en los roles de la bd: " + nombrerol);
    }
    Object estaarea = jComboBoxArea.getSelectedItem();
    System.out.println("Object estaarea = jComboBoxArea.getSelectedItem(): " + estaarea);
    String nombrearea = estaarea.toString();
    System.out.println("String nombrearea = estaarea.toString(): " + nombrearea);
    try {
        area = contrArea.buscarAreaNombre(nombrearea);
        System.out.println("area = contrArea.buscarAreaNombre(nombrearea): " + area);
    } catch (Exception e) {
        e.printStackTrace(System.out);
        System.out.println("no encontró el nombre del area seleccionada en las areas de la bd: " + nombrearea);
    }
    if (area != null && rol != null) {
        int areaSelec = area.getIdArea();
        System.out.println("int areaSelec = area.getIdArea(): " + areaSelec);
        int rolSelec = rol.getIdRol();
        System.out.println("int rolSelec = rol.getIdRol(): " + rolSelec);
        try {
            listaModulosASeleccionar = controladorRolareamodulo.buscarRolareamodulo_X_idRol_idArea(rol, area); //*************** codigo Ivana(Rol) listar.get(rolSelec), (Area) listaa.get(areaSelec));
        } catch (Exception e) {
            JOptionPane.showMessageDialog(this, "\nEl rol y área seleccionados \n no traen módulos.\n ", "Selección para establecer permisos", JOptionPane.ERROR_MESSAGE);
        }
        if (listaModulosASeleccionar != null && !listaModulosASeleccionar.isEmpty()) {  //ESTE IF PUEDE IR ADENTRO DEL TRY
            cargarTabla(listaModulosASeleccionar);
        } else {
            JOptionPane.showMessageDialog(this, "\nEl rol y área seleccionados no han \n sido asociados a ningún módulo.\n ", "Selección para establecer permisos", JOptionPane.ERROR_MESSAGE);
        }
    }
}//GEN-LAST:event_jButtonBuscarModActionPerformed

private void jComboBoxRolActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxRolActionPerformed
}//GEN-LAST:event_jComboBoxRolActionPerformed

//static public int[] seleccionados = null;
private void jButtonRedefinirPermisosSeleccActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRedefinirPermisosSeleccActionPerformed
    boolean hayCambio = false;
    int ctosCambiosSeSeleccionaron = 0;
    int ctosCambiosSeActualizaron = 0;
    String permisosNoActualizados = null;
    String permisosActualizados = null;
    for (int s = 0; s < jTablePermisos.getRowCount(); s++) {
        Object idRolareamodulo = jTablePermisos.getValueAt(s, 0);//id
        System.out.println("el valor de id del permiso de la fila: " + s + "+1 es: " + idRolareamodulo);
        Rolareamodulo ram = new Rolareamodulo();
        boolean chequeado;
        if (!(jTablePermisos.getValueAt(s, 1).equals(listaModulosASeleccionar.get(s).getVisible()))) {
            hayCambio = true;
            ctosCambiosSeSeleccionaron = ctosCambiosSeSeleccionaron + 1;
            if (jTablePermisos.getValueAt(s, 1).equals(false)) {
                chequeado = false;
            } else {
                chequeado = true;
            }
            ram = listaModulosASeleccionar.get(s);
            ram.setVisible(chequeado);
            try {
                controladorRolareamodulo.modificarRolAreaModulo(ram);
                ctosCambiosSeActualizaron = ctosCambiosSeActualizaron + 1;
                if (permisosActualizados == null) {
                    permisosActualizados = "";
                    permisosActualizados = permisosActualizados + jTablePermisos.getValueAt(s, 0);
                } else {
                    permisosActualizados = permisosActualizados + ", " + jTablePermisos.getValueAt(s, 0);
                }
            } catch (Exception e) {
                System.out.println("Excepción: " + e);
                if (permisosNoActualizados == null) {
                    permisosNoActualizados = "";
                    permisosNoActualizados = permisosNoActualizados + jTablePermisos.getValueAt(s, 0);
                } else {
                    permisosNoActualizados = permisosNoActualizados + ", " + jTablePermisos.getValueAt(s, 0);
                }
            }
        }
    }
    if (!(hayCambio)) {
        JOptionPane.showMessageDialog(this, "Debe cambiar un permiso para redefinirlo!", "Redefinir Permisos", JOptionPane.INFORMATION_MESSAGE);
    }
    if (ctosCambiosSeSeleccionaron == ctosCambiosSeActualizaron) {
        JOptionPane.showMessageDialog(this, "Los permisos se modificaron exitosamente!", "Redefinir Permisos", JOptionPane.INFORMATION_MESSAGE);
        System.out.println("Los permisos q se modificaron son: " + permisosActualizados);
    } else if (ctosCambiosSeSeleccionaron > ctosCambiosSeActualizaron) {
        JOptionPane.showMessageDialog(this, "No se pudieron modificar los sgtes permisos: " + permisosNoActualizados, "Redefinir Permisos", JOptionPane.WARNING_MESSAGE);
    } else {
        JOptionPane.showMessageDialog(this, "Hubieron problemas al actualizar los permisos, \n  por favor presione 'Buscar Permisos Actuales', \n revise los cambios y, en caso necesario, \n presione 'Redefinir Permisos' nuevamente.", "Redefinir Permisos", JOptionPane.ERROR_MESSAGE);
    }
}//GEN-LAST:event_jButtonRedefinirPermisosSeleccActionPerformed

private void jTablePermisosMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTablePermisosMouseClicked
}//GEN-LAST:event_jTablePermisosMouseClicked

private void jScrollPane1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jScrollPane1MouseClicked
}//GEN-LAST:event_jScrollPane1MouseClicked

private void jComboBoxAreaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxAreaActionPerformed
}//GEN-LAST:event_jComboBoxAreaActionPerformed

private void jTablePermisosPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_jTablePermisosPropertyChange
}//GEN-LAST:event_jTablePermisosPropertyChange

private void jComboBoxRolItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboBoxRolItemStateChanged
    DefaultTableModel modelo = (DefaultTableModel) jTablePermisos.getModel();
    if (jTablePermisos.getRowCount() > 0) {
        try {
            modelo.setRowCount(0);
            JOptionPane.showMessageDialog(this, "Presionar 'Buscar Permisos Actuales' para cargar los permisos asociados a la selección ", "Permisos", JOptionPane.INFORMATION_MESSAGE);
            //System.out.println("la tabla permisos debería tener ahora 0 filas (al cambiar el rol): " + modelo.getRowCount() );
        } catch (Exception e) {
            JOptionPane.showMessageDialog(this, "\nNo se pudo limpiar la tabla de permisos al cambiar el rol seleccionado, \nfuerce la actualización de la tabla mediante el botón \n'Buscar Permisos Actuales'.", "Actualice pulsando 'Buscar Permisos Actuales'", JOptionPane.INFORMATION_MESSAGE);
        }
    }
}//GEN-LAST:event_jComboBoxRolItemStateChanged

private void jComboBoxAreaItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboBoxAreaItemStateChanged
    DefaultTableModel modelo = (DefaultTableModel) jTablePermisos.getModel();
    if (jTablePermisos.getRowCount() > 0) {
        try {
            modelo.setRowCount(0);
            JOptionPane.showMessageDialog(this, "Presionar 'Buscar Permisos Actuales' para cargar los permisos asociados a la selección ", "Permisos", JOptionPane.INFORMATION_MESSAGE);
            //System.out.println("la tabla permisos debería tener ahora 0 filas (al cambiar el área): " + modelo.getRowCount() );
        } catch (Exception e) {
            JOptionPane.showMessageDialog(this, "\nNo se pudo limpiar la tabla de permisos al cambiar el área seleccionada, \nfuerce la actualización de la tabla mediante el botón \n'Buscar Permisos Actuales'.", "Actualice pulsando 'Buscar Permisos Actuales'", JOptionPane.INFORMATION_MESSAGE);
        }
    }
}//GEN-LAST:event_jComboBoxAreaItemStateChanged

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    CargarModulosPorOperario();    // TODO add your handling code here:
}//GEN-LAST:event_jButton1ActionPerformed

private void jTablemodulosMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTablemodulosMouseClicked
    cargarTablaMóduloPorACR();  // TODO add your handling code here:
}//GEN-LAST:event_jTablemodulosMouseClicked

    /*  public static void main(String args[]) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException {
    UIManager.setLookAndFeel("de.javasoft.plaf.synthetica.SyntheticaBlueIceLookAndFeel");
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    Permisos p = new Permisos();
    p.setLocationRelativeTo(null);
    p.setVisible(true);
    }
    });
    }
     */
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.persistence.EntityManager GestorPesajeJpaPU2EntityManager;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButtonBuscarMod;
    private javax.swing.JButton jButtonRedefinirPermisosSelecc;
    private javax.swing.JButton jButtonSalir;
    private javax.swing.JComboBox jComboBoxAN;
    private javax.swing.JComboBox jComboBoxArea;
    private javax.swing.JComboBox jComboBoxRol;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabelApellidoCon;
    private javax.swing.JLabel jLabelApellidoCon2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTable jTablePermisos;
    private javax.swing.JTable jTablem;
    private javax.swing.JTable jTablemodulos;
    private javax.swing.JTextField jTextFieldUsuario3;
    private javax.swing.JTextField jTextFieldUsuario4;
    private java.util.List<Entidades.Operario> operarioList;
    private javax.persistence.Query operarioQuery;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables

    private void CargarModulosPorOperario() {
        try {
            System.out.println("en metodo operol");
            String[] encabezados = new String[3];
            encabezados[0] = "Area";
            encabezados[1] = "Rol";
            encabezados[2] = "Cargo";
            // encabezados[3] = "Modulo";

            String[] encabezados1 = new String[2];
            encabezados1[0] = "Módulos";
            encabezados1[1] = "Activo / No Activo";

            tableModel = new TablaPersonalizada(encabezados);
            tableModel1 = new TablaPersonalizada(encabezados1);

            jTablemodulos.setModel(tableModel);
            jTablem.setModel(tableModel1);

            String op = jComboBoxAN.getSelectedItem().toString();
            Operario oper = controladoroperario.buscarOperarioApellido(op);
            System.out.println(oper + "operol");
            operol = (List) ctrloperariorol.buscarOperariorol_X_idOperario(oper.getIdoperario());
            System.out.println(operol + "operol");
            //    List listmodulos = controladorRolareamodulo.buscarTodosRolAreaModulo();
            // System.out.println(listContrato + "listacontrato en cargar contratos por prov");
            //  Contrato c = new Contrato();
            // c = (Contrato) controladorcontrato.buscarTodosContrato();

            //  if(listContrato.contains(c.getProveedor().getRazonSocialProveedor().equals(prov))
            for (int i = 0; i < operol.size(); i++) {
                //for (int j = 0; j < operol.size(); j++) {
                Vector fila = new Vector();
                Vector fila1 = new Vector();
                Operariorol orol = (Operariorol) operol.get(i);
                Rolareamodulo ram = new Rolareamodulo();

                Area a = orol.getArea();
                Rol r = orol.getRol();
                List modulos = controladorRolareamodulo.BuscarModulos(a, r);
                ram = (Rolareamodulo) modulos.get(i);


                boolean b = ctrloperariorol.BuscarAR(a, r, oper);
                boolean m = controladorRolareamodulo.BuscarAR(a, r);
                if (b && m) {

                    fila.add(orol.getArea().getNombreArea());
                    fila.add(orol.getRol().getNombreRol());
                    fila.add(orol.getCargo().getNombreCargo());


                    //}
                    fila1.add(ram.getModulo().getNombreModulo());
                    fila1.add(ram.getVisible());
                    tableModel.addRow(fila);
                    tableModel1.addRow(fila1);
                }
            }
        } catch (Exception ex) {
            Logger.getLogger(Permisos.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void cargarTablaMóduloPorACR() {

        int fila = jTablemodulos.getSelectedRow();
        Operariorol or = (Operariorol) operol.get(fila);

        List<Rolareamodulo> ram = controladorRolareamodulo.BuscarModulos(or.getArea(), or.getRol());
        String[] encabezados1 = new String[2];
        encabezados1[0] = "Módulos";
        encabezados1[1] = "Activo / No Activo";

        tableModel1 = new TablaPersonalizada(encabezados1);

        jTablem.setModel(tableModel1);
        for (int i = 0; i < ram.size(); i++) {
            Vector fila3 = new Vector();

            if (ram.get(i).getVisible() ){
                fila3.add(ram.get(i).getModulo().getNombreModulo());
                fila3.add(ram.get(i).getVisible());

                tableModel1.addRow(fila3);
            }
        }

    }
}
